<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>案件管理-案件维护</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style>
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <!--案件维护-->
                    <div id="whForm" class="layui-card-body" hidden="hidden">
                        <!-- 综合填写 -->
                        <form id="zhEdit" class="layui-form layui-row layui-col-space16" action="" lay-filter="demo-val-filter">
                            <label for="jcajxxuuid"></label><input type="text" id="jcajxxuuid" style="display: none">
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 10px;">
                                <legend>综合岗-填写</legend>
                            </fieldset>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">案源类型 :</label>
                                    <div class="layui-input-block" style="width: 310px;margin-left: 180px">
                                        <label for="aylxSelect"></label>
                                        <select id="aylxSelect" class="layui-input" autocomplete="off"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">备注 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="bz"></label><input type="text" id="bz" placeholder="请输入备注" class="layui-input"
                                                                       style="width: 300px"
                                                                       autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">要求结案时间 :</label>
                                    <div class="layui-input-block">
                                        <label for="yqjasj"></label><input type="text" id="yqjasj" placeholder="yyyy-MM-dd"
                                                                           class="layui-input" style="width: 300px"
                                                                           autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">联合侦办 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="lhzb"></label><input type="text" id="lhzb" class="layui-input"
                                                                         placeholder="请输入联合侦办" style="width: 300px"
                                                                         autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                                <legend>审核岗-填写</legend>
                            </fieldset>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">走逃情况 :</label>
                                    <div class="layui-input-block">
                                        <label for="ztqk"></label><input type="text" id="ztqk" class="layui-input"
                                                                         placeholder="请输入走逃情况" style="width: 300px"
                                                                         autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">是否虚开 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="sfxk"></label><input type="text" id="sfxk" class="layui-input"
                                                                         placeholder="请输入是否虚开" style="width: 300px"
                                                                         autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">移送公安情况 :</label>
                                    <div class="layui-input-block">
                                        <label for="ysgaqk"></label><input type="text" id="ysgaqk" class="layui-input"
                                                                           placeholder="请输入移送公安情况"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/对外/发票份数 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="zpdwfpfs"></label><input type="text" id="zpdwfpfs" class="layui-input"
                                                                             placeholder="请输入专票/对外/发票份数"
                                                                             style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/对外/金额 :</label>
                                    <div class="layui-input-block">
                                        <label for="zpdwje"></label><input type="text" id="zpdwje" class="layui-input"
                                                                           placeholder="请输入专票/对外/金额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/对外/税额 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="zpdwse"></label><input type="text" id="zpdwse" class="layui-input"
                                                                           placeholder="请输入专票/对外/税额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/接受/发票份数 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="zpjsfpfs"></label><input type="text" id="zpjsfpfs" class="layui-input"
                                                                             placeholder="请输入专票/接受/发票份数"
                                                                             style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/接受/金额 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="zpjsje"></label><input type="text" id="zpjsje" class="layui-input"
                                                                           placeholder="请输入专票/接受/金额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">专票/接受/税额 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="zpjsse"></label><input type="text" id="zpjsse" class="layui-input"
                                                                           placeholder="请输入专票/接受/税额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/对外/发票份数 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="ppdwfpfs"></label><input type="text" id="ppdwfpfs" class="layui-input"
                                                                             placeholder="请输入普票/对外/发票份数"
                                                                             style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/对外/金额 :</label>
                                    <div class="layui-input-block">
                                        <label for="ppdwje"></label><input type="text" id="ppdwje" class="layui-input"
                                                                           placeholder="请输入普票/对外/金额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/对外/税额 :</label>
                                    <div class="layui-input-block">
                                        <label for="ppdwse"></label><input type="text" id="ppdwse" class="layui-input"
                                                                           placeholder="请输入普票/对外/税额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/接受/发票份数 :</label>
                                    <div class="layui-input-block">
                                        <label for="ppjsfpfs"></label><input type="text" id="ppjsfpfs" class="layui-input"
                                                                             placeholder="请输入普票/接受/发票份数"
                                                                             style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md6">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/接受/金额 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="ppjsje"></label><input type="text" id="ppjsje" class="layui-input"
                                                                           placeholder="请输入普票/接受/金额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md12">
                                <div class="layui-form-item" style="margin-bottom: 0;">
                                    <label class="layui-form-label" style="width: 150px">普票/接受/税额 :</label>
                                    <div class="layui-input-block" style="width: 380px">
                                        <label for="ppjsse"></label><input type="text" id="ppjsse" class="layui-input"
                                                                           placeholder="请输入普票/接受/税额"
                                                                           style="width: 300px" autocomplete="off">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row" style="margin-top: 10px;display: flex; justify-content: center;">
                                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
                                <button type="button" class="layui-btn" lay-submit="" lay-filter="back">返回</button>
                            </div>
                        </form>
                        <!-- 审理填写 -->
                    </div>
                    <!--案件列表-->
                    <div id="ajForm" class="layui-card-body">
                        <form id="searchForm" class="layui-form" method="post" style="margin-left: 10px">
                            <div class="layui-form-item">
                                <div class="layui-row">
                                    <div class="layui-col-xs3">
                                        <label for="jcajbh"></label>
                                        <input type="text" id="jcajbh" class="layui-input" autocomplete="off"
                                               placeholder="请输案件编号">
                                    </div>
                                    <div class="layui-col-xs3">
                                        <label for="nsrsbh"></label>
                                        <input type="text" id="nsrsbh" class="layui-input" autocomplete="off"
                                               placeholder="请输纳税人识别号">
                                    </div>
                                    <div class="layui-col-xs3">
                                        <label for="nsrmc"></label>
                                        <input type="text" id="nsrmc" class="layui-input" autocomplete="off"
                                               placeholder="请输入纳税人名称">
                                    </div>
                                    <div class="layui-col-xs3">
                                        <label for="ayxfsj"></label>
                                        <input type="text" class="layui-input" id="ayxfsj"
                                               placeholder="请输入案源下发时间">
                                    </div>
                                </div>
                                <div class="layui-row" style="margin-top: 20px;display: flex; justify-content: center;">
                                    <button type="button" class="layui-btn" lay-submit="" lay-filter="search">查询</button>
                                    <button type="button" class="layui-btn" lay-submit="" lay-filter="reset">重置</button>
                                </div>
                            </div>
                            <table class="layui-hide" id="ajwh_table" lay-filter="ajwh_table"></table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/html" id="ajwhtool">
    <a class="layui-btn layui-btn-xs" lay-event="ajwhBtn">案件维护</a>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    //获取token
    var token = CoreUtil.getData("access_token");
    //地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var tableIns1;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var startTime = null;
    var endTime = null;
    //要求结案时间
    var yqjasjTime = null;
    layui.use(['table', 'laypage', 'layer', 'laydate'], function () {
        // 案源字典下拉选
        CoreUtil.sendPost("/attention/attentionMgr/queryAylxzdList", null, function (res) {
            if (res.code === 0) {
                let value = res.data; // 接口返回的数据
                let opt = "<option value=''>请选择科室</option>"; // 默认选项
                // 遍历接口返回的数据，生成选项
                for (let i in value) {
                    opt += '<option value="' + value[i].zdmc + '">' + value[i].zdmc + '</option>';
                }
                // 将生成的选项插入到 select 元素中
                $("#aylxSelect").html(opt);
                // 渲染 layui 的 select 组件
                form.render('select'); // 注意：必须调用渲染方法以更新 select 组件
            } else {
                // 如果接口返回错误
                layer.msg(res.msg, {icon: 2}); // 提示错误信息
                return false;
            }
        });
        // 案件列表
        tableIns1 = table.render({
            elem: '#ajwh_table'
            , page: true //开启分页
            , contentType: 'application/json'
            , headers: {"authorization": token}
            , url: '/attention/attentionMgr/queryAjwhTable' //数据接口
            , method: 'POST'
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null : res.data.records //解析数据列表
                }
            }
            , cols: [
                [
                    {field: 'jcajxxuuid', title: '稽查案件信息uuid', width: 100, hide: true},
                    {field: 'jcajbh', title: '案件编号', width: 200, align: "center", sort: true},
                    {field: 'nsrsbh', title: '纳税人识别号', width: 200, align: "center", sort: true},
                    {field: 'nsrmc', title: '企业名称', width: 200, align: "center", sort: true},
                    {
                        field: 'ayxfsj',
                        title: '案源下发时间',
                        width: 160,
                        align: "center",
                        sort: true,
                        templet: function (d) {
                            if (!d.ayxfsj) {
                                return '';
                            }
                            return layui.util.toDateString(d.ayxfsj, 'yyyy-MM-dd');
                        }
                    },
                    {field: 'ajjczt', title: '案件检查状态', width: 140, align: "center", sort: true},
                    {field: 'jcfs', title: '检查方式', width: 100, align: "center", sort: true},
                    {field: 'zxqk', title: '注销情况', width: 100, align: "center", sort: true},
                    {field: 'cbhj', title: '查补合计', width: 150, align: "center", sort: true},
                    {field: 'rkhj', title: '入库合计', width: 150, align: "center", sort: true},
                    {toolbar: '#ajwhtool', title: '操作', width: 120, align: 'center', fixed: 'right'}
                ]
            ]
            , toolbar: '#toolbar1'
        });
        //案源下发时间
        laydate.render({
            elem: '#ayxfsj'
            , type: 'date'
            , range: '~'
            , done: function (value, date, endDate) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }
            }
        });
        //要求结案时间
        //立案时间起
        laydate.render({
            elem: '#yqjasj'
            , type: 'date'
            , value: null
            , done: function (value) {
                if (value !== null && value !== undefined && value !== "") {
                    yqjasjTime = value;
                } else {
                    yqjasjTime = null;
                }
            }
        });
        //查询
        form.on('submit(search)', function () {
            searchAjwhList();
        })
        //页面查询条件重置按钮
        form.on('submit(reset)', function () {
            document.getElementById('searchForm').reset(); // 原生重置表单
            $('#ayxfsj').val(''); // 清空输入框
            startTime = null; // 重置开始时间
            endTime = null; // 重置结束时间
            form.render(); // 重新渲染 Layui 的动态组件
        })
        //案件维护
        table.on('tool(ajwh_table)', function (obj) {
            const data = obj.data; // 当前行数据
            const layEvent = obj.event; // 获取lay-event的值
            if (layEvent === 'ajwhBtn') {
                //给表单赋值
                setSdbbContent(data);
                // 比如弹出一个编辑窗口
                $("#whForm").show();
                $("#ajForm").hide();
            }
        });
        //提交案件维护信息
        form.on('submit(submit)', function (data) {
            const whereParams = {
                "jcajxxuuid": $("#jcajxxuuid").val(),
                "aylx": $("#aylxSelect").val(),
                "bz": $("#bz").val(),
                "yqjasj": $("#yqjasj").val(),
                "ztqk": $("#ztqk").val(),
                "sfxk": $("#sfxk").val(),
                "lhzb": $("#lhzb").val(),
                "ysgaqk": $("#ysgaqk").val(),
                "zpdwfpfs": $("#zpdwfpfs").val(),
                "zpdwje": $("#zpdwje").val(),
                "zpdwse": $("#zpdwse").val(),
                "zpjsfpfs": $("#zpjsfpfs").val(),
                "zpjsje": $("#zpjsje").val(),
                "zpjsse": $("#zpjsse").val(),
                "ppdwfpfs": $("#ppdwfpfs").val(),
                "ppdwje": $("#ppdwje").val(),
                "ppdwse": $("#ppdwse").val(),
                "ppjsfpfs": $("#ppjsfpfs").val(),
                "ppjsje": $("#ppjsje").val(),
                "ppjsse": $("#ppjsse").val(),
            };
            CoreUtil.sendPost("/attention/attentionMgr/saveAjwhxxList", whereParams, function (res) {
                if (res.code === 0) {
                    layer.msg("保存成功！", {icon: 1}); // 提示错误信息
                    searchAjwhList();
                } else {
                    // 如果接口返回错误
                    layer.msg(res.msg, {icon: 2}); // 提示错误信息
                    return false;
                }
            });
        })
        //返回
        form.on('submit(back)', function () {
            $("#whForm").hide();
            $("#ajForm").show();
        })

        //给表单赋值
        function setSdbbContent(data) {
            $("#jcajxxuuid").val(data.jcajxxuuid);
            $("#aylxSelect").val(data.aylx);
            layui.form.render('select');  // 重新渲染layui的select
            $("#bz").val(data.bz);
            $("#yqjasj").val(data.yqjasj);
            $("#ztqk").val(data.ztqk);
            $("#sfxk").val(data.sfxk);
            $("#ysgaqk").val(data.ysgaqk);
            $("#lhzb").val(data.lhzb);
            $("#zpdwfpfs").val(data.zpdwfpfs);
            $("#zpdwje").val(data.zpdwje);
            $("#zpdwse").val(data.zpdwse);
            $("#ppdwfpfs").val(data.ppdwfpfs);
            $("#ppdwje").val(data.ppdwje);
            $("#ppdwse").val(data.ppdwse);
            $("#ppjsfpfs").val(data.ppjsfpfs);
            $("#ppjsje").val(data.ysgaqk);
            $("#ppjsse").val(data.ysgaqk);
            $("#zpjsfpfs").val(data.ysgaqk);
            $("#zpjsje").val(data.ysgaqk);
            $("#zpjsse").val(data.ysgaqk);
        }

        //查询案件信息
        function searchAjwhList() {
            tableIns1.reload({
                contentType: 'application/json'
                , headers: {
                    "authorization": token,
                }
                , where: {
                    "nsrsbh": $("#nsrsbh").val(),
                    "nsrmc": $("#nsrmc").val(),
                    "jcajbh": $("#jcajbh").val(),
                    "startTime": startTime,
                    "endTime": endTime,
                }, page: {
                    curr: 1 //重新从第 1 页开始
                }
            }, false);
        }
    });
</script>
</body>

</html>